
#ifndef CHATPROJECT_GRADIENTBUTTON_H
#define CHATPROJECT_GRADIENTBUTTON_H

#include <QAbstractButton>

class QPropertyAnimation;

class GradientButton : public QAbstractButton
{
    Q_OBJECT
    Q_PROPERTY(int spread READ spread WRITE setSpread)
public:
    explicit GradientButton(QWidget *parent = nullptr);
    explicit GradientButton(const QString& str, QWidget *parent = nullptr);
    ~GradientButton() override;
    int spread() const { return spread_; }
    void setSpread(int spread) { spread_ = spread;  }
    void setColor(const QColor &color) { color_ = color; }
    // 提供尺寸提示
    QSize sizeHint() const override {
        return {80, 30};  // 默认按钮大小
    }

protected:
    void enterEvent(QEvent *event) override;
    void paintEvent(QPaintEvent *event) override;
    void valueChanged(const QVariant &value);

private:
    QPropertyAnimation*     animation_;
    int                     spread_;
    bool                    filled_;
    QColor                  color_;
    QString                 text_;
};


#endif //CHATPROJECT_GRADIENTBUTTON_H
